package com.rich.house.controller;


import com.rich.common.entity.TbWantHouse;
import com.rich.house.service.WantHouseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author hu
 * @Date:2021/8/25
 */
@RequestMapping("/want")
@RestController
public class WantHouseController {

    @Autowired
    private WantHouseService wantHouseService;

    /**
     * 想租(买)房 列表
     *
     * @return TbWantHouse
     */
    @GetMapping("/wantHouseList")
    public List<TbWantHouse> wantHouseList(){
        return wantHouseService.wantHouseList();
    }

    /**
     * 我想租(买)个房
     * @param wantHouse
     */
    @PostMapping("/addWantHouse")
    public void addWantHouse(@RequestBody TbWantHouse wantHouse){
        try{
            wantHouseService.addWantHouse(wantHouse);
        }catch (Exception e){
            e.printStackTrace();
        }
    }

    /**
     * 逻辑删除
     *
     * @param id
     * @param status
     */
    @DeleteMapping("/deleteWantHouse/{id}/{status}")
    public void deleteWantHouse(@PathVariable("id")Long id,@PathVariable("status")String status){
        wantHouseService.deleteWantHouse(id,status);
    }

}
